//
//  ActivityListTableViewCell.m
//  豆瓣
//
//  Created by dllo on 15/10/27.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "ActivityListTableViewCell.h"
#import "UIImageView+WebCache.h"

@implementation ActivityListTableViewCell


-(void)dealloc
{
    [_nameLabel release];
    [_kindLabel release];
    [_timeLabel release];
    [_addressLabel release];
    [_interestLabel release];
    [_attendLabel release];
    [_participant_count release];
    [_wisher_count release];
    [_aImage release];
    [_bImage release];
    [_cImage release];
    [_dImage release];
    [_eImage release];
    [_fImage release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubViews];
        
    }
    return self;
}

- (void)createSubViews
{
    self.aImage = [[UIImageView alloc]initWithFrame:CGRectMake(15, 10, 345, 160)];
    self.aImage.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    [self.contentView addSubview:self.aImage];
    [self.aImage release];
    
    
    self.bImage = [[UIImageView alloc]initWithFrame:CGRectMake(2, 30, 341, 120)];
    self.bImage.image = [UIImage imageNamed:@"bg_share_large.png"];
    [self.aImage addSubview:self.bImage];
    [self.bImage release];
    
    
    self.cImage = [[UIImageView alloc]initWithFrame:CGRectMake(245, 5, 88, 108)];
    self.cImage.backgroundColor = [UIColor yellowColor];
    [self.bImage addSubview:self.cImage];
    [self.cImage release];
    
    self.dImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 25, 20)];
    self.dImage.image = [UIImage imageNamed:@"icon_date.png"];
    [self.bImage addSubview:self.dImage];
    [self.dImage release];
    
    
    self.eImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 35, 25, 20)];
    self.eImage.image = [UIImage imageNamed:@"icon_spot.png"];
    [self.bImage addSubview:self.eImage];
    [self.eImage release];
    
    
    self.fImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 60, 25, 20)];
    self.fImage.image = [UIImage imageNamed:@"icon_catalog.png"];
    [self.bImage addSubview:self.fImage];
    [self.fImage release];
    
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 335, 20)];
    self.nameLabel.backgroundColor = [UIColor whiteColor];
    [self.aImage addSubview:self.nameLabel];
    [self.nameLabel release];
    
    UILabel *aLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 90, 50, 20)];
    aLabel.text = @"感兴趣:";
    aLabel.font = [UIFont systemFontOfSize:15];
    [self.bImage addSubview:aLabel];
    [aLabel release];
    
    UILabel *bLabel = [[UILabel alloc] initWithFrame:CGRectMake(130, 90, 50, 20)];
    bLabel.text = @"参加:";
    bLabel.font = [UIFont systemFontOfSize:15];
    [self.bImage addSubview:bLabel];
    [bLabel release];
    
    UILabel *cLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 60, 40, 20)];
    cLabel.text = @"类型:";
    cLabel.font = [UIFont systemFontOfSize:15];
    [self.bImage addSubview:cLabel];
    [cLabel release];
    
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 10, 180, 20)];
    self.timeLabel.backgroundColor = [UIColor whiteColor];
    [self.bImage addSubview:self.timeLabel];
    [self.timeLabel release];
    
    
    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 35, 180, 20)];
    self.addressLabel.backgroundColor = [UIColor whiteColor];
    [self.bImage addSubview:self.addressLabel];
    [self.addressLabel release];
    
    
    self.kindLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 60, 140, 20)];
    self.kindLabel.backgroundColor = [UIColor whiteColor];
    [self.bImage addSubview:self.kindLabel];
    [self.kindLabel release];
    
    
    self.participant_count = [[UILabel alloc] initWithFrame:CGRectMake(160, 90, 60, 20)];
    self.participant_count.backgroundColor = [UIColor whiteColor];
    [self.bImage addSubview:self.participant_count];
    [self.participant_count release];
    
    self.wisher_count = [[UILabel alloc] initWithFrame:CGRectMake(60, 90, 60, 20)];
    self.wisher_count.backgroundColor = [UIColor whiteColor];
    [self.bImage addSubview:self.wisher_count];
    [self.wisher_count release];
    
    
}

- (void)setAActivity:(Activity *)aActivity
{
    if (_aActivity != aActivity) {
        
        [_aActivity release];
        _aActivity = [aActivity retain];
        
    }
    
    self.nameLabel.text = _aActivity.title;
    self.addressLabel.text = _aActivity.address;
    self.kindLabel.text = _aActivity.category_name;
    self.timeLabel.text = _aActivity.begin_time;
    self.wisher_count.text = [NSString stringWithFormat:@"%@", _aActivity.wisher_count];
    self.participant_count.text = [NSString stringWithFormat:@"%@", _aActivity.participant_count];
    
    
    NSURL *url = [NSURL URLWithString:self.aActivity.image];
    
    [self.cImage sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeHoderImage.png"]];

}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
